﻿package
{
	import org.flixel.FlxSprite;
	import org.flixel.FlxG;
	
	
	public class ASExplode extends FlxSprite
	{
		[Embed(source = 'data/explo.png')] private var animExplode:Class;
		[Embed(source = 'data/explo.mp3')] private var sndExplo:Class;
		
		public function ASExplode()
		{
			//super(animExplode,0,0,true);
			super(0, 0);
			width = 16;
			height = 16;
			loadGraphic(animExplode, true, false, width, height, false);
			addAnimation("start", [0, 1, 2, 3], 25, false);
			addAnimation("shipexplode", [0, 1, 2, 3,2,1,0,1,2,3,2,1,0], 5, false);
			visible = false;
			exists = false;
		}

		public function spawn(X:int, Y:int, Color:Number = 0xFFFF0000, ShipExplode:Boolean = false):void
		{
			x = X; y = Y;
			exists = true;
			visible = true;
			
			if (ShipExplode) {
				color = 0xFFFFFFFF;
				play("shipexplode", true);
			}
			else {
				color = Color;
			
				FlxG.play(sndExplo);
				play("start", true);
			}
		}
		
		override public function update():void
		{
			if (_curFrame == 3) {
				exists = false;
				visible = false;
			}
			super.update();
		}
	}

}